//
//  MusicPlayerTool.m
//  audioTest
//
//  Created by Yang Bean on 12/10/11.
//  Copyright (c) 2012年 Yang Bean. All rights reserved.
//

#import "MusicPlayerTool.h"

@implementation MusicPlayerTool

+ (MusicPlayerTool*)sharedInstance {
	static MusicPlayerTool *myInstance = nil;
    if (nil == myInstance) {
        myInstance  = [[[self class] alloc] init];
        
    }
    return myInstance;
}
- (void)dealloc
{
    [player stop];
    [player release];
    [super dealloc];
}
- (id)init
{
    self = [super init];
    if (self) {
        player = nil;
    }
    return self;
}
- (void)playBG_MusicWithPath:(NSString*)path
{
    NSString *soundPath=[[NSBundle mainBundle] pathForResource:path ofType:@"mp3"];
    NSURL *soundUrl=[[NSURL alloc] initFileURLWithPath:soundPath];
    
    if (player != nil) {
        [player stop];
        [player release];
    }
    
    
    player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundUrl error:nil];
    
    
    [player setVolume:0.5f];
    
    [player play];
    
    [soundUrl release];
}
- (void)ppp
{
    NSLog(@"ppp");
}
@end
